
#include "dev_purifier.h"
#include "page_base.h"
#include "img_common.h"
#include "pt_ipc.h"
#include "pt_fs.h"
#include "sys_font.h"

#define  DEBUG_PURI   1

static char* icon_washing[2] = 
{
    "WashFilterElement_Default.png",
    "WashFilterElement_Selected.png",
};

static char* icon_heating[2] = 
{
    "Heat_Default.png",
    "Heat1_Selected.png",
};

static char* puri_wsta[] = 
{
	"待机中",
	"保温中",
	"加热中",
	"冲洗中",
	"制水中",
	"出水中",
	"UV杀菌中",
	"故障中",	
};

static int dev_purifier_wash_onoff(ui_dev_purifier_t* puri)
{
	puri_http_req_t req;

    memset(&req,0,sizeof(puri_http_req_t));

	req.cmd_type = PURI_CMD_WASH;
	req.cmd_data = puri->data.wash_status;
    
    snprintf(req.devid,sizeof(req.devid),"%s",puri->data.devid);

    pt_ipc_send_msg(KH_DEV_PURI_CTRL,(void*)&req,sizeof(puri_http_req_t));

	return 0;
}

static void dev_purifier_wash_event_callback(lv_event_t* event)
{
    ui_dev_purifier_t* puri     = NULL;
    puri = (ui_dev_purifier_t*)lv_event_get_user_data(event);

    switch(event->code){
    case LV_EVENT_CLICKED:
    {
		debug_d("wash_status=%d\n",puri->data.wash_status);
        puri->data.wash_status = !puri->data.wash_status;
		lv_img_set_src(puri->ui.wash_img,pt_fs_get(icon_washing[puri->data.wash_status]));
        
		dev_purifier_wash_onoff(puri);
		break;
    }
	default:break;
	}
}

static int dev_purifier_heat_onoff(ui_dev_purifier_t* puri)
{
	puri_http_req_t req;

    memset(&req,0,sizeof(puri_http_req_t));

	req.cmd_type = PURI_CMD_HEAT;
	req.cmd_data = puri->data.heat_status;

    snprintf(req.devid,sizeof(req.devid),"%s",puri->data.devid);

    pt_ipc_send_msg(KH_DEV_PURI_CTRL,(void*)&req,sizeof(puri_http_req_t));

	return 0;
}

static void dev_purifier_heat_event_callback(lv_event_t* event)
{
    ui_dev_purifier_t* puri     = NULL;
    puri = (ui_dev_purifier_t*)lv_event_get_user_data(event);

    switch(event->code){
    case LV_EVENT_CLICKED:
    {
		debug_d("heat_status=%d\n",puri->data.heat_status);
        puri->data.heat_status = !puri->data.heat_status;
		lv_img_set_src(puri->ui.heat_img,pt_fs_get(icon_heating[puri->data.heat_status]));
              	   
	   	dev_purifier_heat_onoff(puri);
	   
	    break;
    }
	default:break;
	}
}

//滤芯冲洗 加热按钮
static int ui_puri_ctl_button(lv_obj_t* superview,ui_dev_purifier_t* puri)
{
	puri->ui.wash_img = lv_img_create(superview);
	lv_img_set_src(puri->ui.wash_img,pt_fs_get(icon_washing[puri->data.wash_status]));
	lv_obj_set_pos(puri->ui.wash_img, 67, 195);
	lv_obj_set_size(puri->ui.wash_img, 86, 86);

	puri->ui.wash_lab = lv_label_create(superview);
	lv_label_set_text(puri->ui.wash_lab, "滤芯冲洗");
	lv_label_set_long_mode(puri->ui.wash_lab, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(puri->ui.wash_lab,55,290);
	lv_obj_set_size(puri->ui.wash_lab, 116,20);
	lv_obj_set_style_text_align(puri->ui.wash_lab,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.wash_lab,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.wash_lab,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
	lv_obj_set_style_text_font(puri->ui.wash_lab, lv_font_get(20), LV_PART_MAIN);
	//************************************************************
	puri->ui.wash_btn = lv_obj_create(superview);

    lv_obj_set_pos(puri->ui.wash_btn,67,195);
    lv_obj_set_size(puri->ui.wash_btn,96,96);

	lv_obj_set_style_radius(puri->ui.wash_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_border_width(puri->ui.wash_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_border_color(puri->ui.wash_btn, lv_color_make(0x00, 0x00, 0x00), LV_PART_MAIN);
	lv_obj_set_style_border_opa(puri->ui.wash_btn, LV_OPA_0, LV_PART_MAIN);

	lv_obj_set_style_outline_width(puri->ui.wash_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_shadow_width(puri->ui.wash_btn, 0, LV_PART_MAIN);
	lv_obj_set_scrollbar_mode(puri->ui.wash_btn, LV_SCROLLBAR_MODE_OFF);
	lv_obj_set_style_pad_all(puri->ui.wash_btn, 0,0);

    #if 1
    lv_obj_set_style_bg_opa(puri->ui.wash_btn,LV_OPA_0,0);
    #else
    lv_obj_set_style_bg_opa(puri->ui.wash_btn,LV_OPA_100,0);
    lv_obj_set_style_bg_color(puri->ui.wash_btn,lv_color_make(0xff,0,0),0);
    #endif
    lv_obj_add_event_cb(puri->ui.wash_btn, dev_purifier_wash_event_callback,LV_EVENT_ALL,(void*)puri);
	//*********************************************************** 

	puri->ui.heat_img = lv_img_create(superview);
	lv_img_set_src(puri->ui.heat_img,pt_fs_get(icon_heating[puri->data.heat_status]));
	lv_obj_set_pos(puri->ui.heat_img, 291, 195);
	lv_obj_set_size(puri->ui.heat_img, 86, 86);

	puri->ui.heat_lab = lv_label_create(superview);
	lv_label_set_text(puri->ui.heat_lab, "加热");
	lv_label_set_long_mode(puri->ui.heat_lab, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(puri->ui.heat_lab, 275,290);
	lv_obj_set_size(puri->ui.heat_lab, 116, 20);
    lv_obj_set_style_text_align(puri->ui.heat_lab,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_opa(puri->ui.heat_lab,LV_OPA_80,LV_PART_MAIN);
    lv_obj_set_style_text_color(puri->ui.heat_lab,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_obj_set_style_text_font(puri->ui.heat_lab, lv_font_get(20), LV_PART_MAIN);
	//*************************
	puri->ui.heat_btn = lv_obj_create(superview);

    lv_obj_set_pos(puri->ui.heat_btn,291,195);
    lv_obj_set_size(puri->ui.heat_btn,96,96);

	lv_obj_set_style_radius(puri->ui.heat_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_border_width(puri->ui.heat_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_border_color(puri->ui.heat_btn, lv_color_make(0x00, 0x00, 0x00), LV_PART_MAIN);
	lv_obj_set_style_border_opa(puri->ui.heat_btn, LV_OPA_0, LV_PART_MAIN);

	lv_obj_set_style_outline_width(puri->ui.heat_btn, 0, LV_PART_MAIN);
	lv_obj_set_style_shadow_width(puri->ui.heat_btn, 0, LV_PART_MAIN);
	lv_obj_set_scrollbar_mode(puri->ui.heat_btn, LV_SCROLLBAR_MODE_OFF);
	lv_obj_set_style_pad_all(puri->ui.heat_btn, 0,0);

    #if 1
    lv_obj_set_style_bg_opa(puri->ui.heat_btn,LV_OPA_0,0);
    #else
    lv_obj_set_style_bg_opa(puri->ui.heat_btn,LV_OPA_100,0);
    lv_obj_set_style_bg_color(puri->ui.heat_btn,lv_color_make(0xff,0,0),0);
    #endif

    lv_obj_add_event_cb(puri->ui.heat_btn, dev_purifier_heat_event_callback,LV_EVENT_ALL,(void*)puri);
	//*****************************************************************

	if((puri->data.is_exist_heat)&&(!puri->data.is_exist_wash))
	{
		//只有加热
		lv_obj_set_pos(puri->ui.heat_btn,200,195);
		lv_obj_set_pos(puri->ui.heat_img,200,195);
		lv_obj_set_pos(puri->ui.heat_lab,185,290);
		//****************************
		lv_obj_add_flag(puri->ui.wash_btn,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.wash_img,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.wash_lab,LV_OBJ_FLAG_HIDDEN);
	}
	else if((!puri->data.is_exist_heat)&&(puri->data.is_exist_wash))
	{
		//只有滤芯冲洗

		lv_obj_add_flag(puri->ui.heat_btn,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.heat_img,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.heat_lab,LV_OBJ_FLAG_HIDDEN);
		//****************************
		lv_obj_set_pos(puri->ui.wash_btn,200,195);
		lv_obj_set_pos(puri->ui.wash_img,200,195);
		lv_obj_set_pos(puri->ui.wash_lab,185,290);
		//****************************
	}
	//*****************************************************************

	return 0;
}

static int ui_puri_mode1_hide(ui_dev_purifier_t* puri)
{
	lv_obj_add_flag(puri->ui.mode1.js,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode1.js_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_add_flag(puri->ui.mode1.cs,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode1.cs_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_add_flag(puri->ui.mode1.filter1,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode1.filter2,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode1.filter3,LV_OBJ_FLAG_HIDDEN);

	return 0;
}

static int ui_puri_mode1_show(ui_dev_purifier_t* puri)
{
	lv_obj_clear_flag(puri->ui.mode1.js,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode1.js_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_clear_flag(puri->ui.mode1.cs,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode1.cs_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_clear_flag(puri->ui.mode1.filter1,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode1.filter2,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode1.filter3,LV_OBJ_FLAG_HIDDEN);

	if(puri->data.filter_num == 1)
	{
		lv_obj_add_flag(puri->ui.mode1.filter2,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode1.filter3,LV_OBJ_FLAG_HIDDEN);
	}
	else if(puri->data.filter_num == 2)
	{
		lv_obj_add_flag(puri->ui.mode1.filter3,LV_OBJ_FLAG_HIDDEN);
	}

	return 0;
}

static int ui_puri_mode1_update(ui_dev_purifier_t* puri)
{
	char txt[128] = {0};

	if(!puri){
		return -1;
	}

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.jstds);
	lv_label_set_text(puri->ui.mode1.js,txt);

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.cstds);
	lv_label_set_text(puri->ui.mode1.cs,txt);

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%s:%d%%",puri->data.f_info[0].name,puri->data.f_info[0].life);
	lv_label_set_text(puri->ui.mode1.filter1,txt);

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%s:%d%%",puri->data.f_info[1].name,puri->data.f_info[1].life);
	lv_label_set_text(puri->ui.mode1.filter2,txt);

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%s:%d%%",puri->data.f_info[2].name,puri->data.f_info[2].life);
	lv_label_set_text(puri->ui.mode1.filter3,txt);

	if(puri->data.filter_num == 1)
	{
		lv_obj_set_pos(puri->ui.mode1.filter1,296,110);
		lv_obj_add_flag(puri->ui.mode1.filter2,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode1.filter3,LV_OBJ_FLAG_HIDDEN);
	}
	else if(puri->data.filter_num == 2)
	{
		lv_obj_set_pos(puri->ui.mode1.filter1,296,90);
		lv_obj_set_pos(puri->ui.mode1.filter2,296,130);
		lv_obj_add_flag(puri->ui.mode1.filter3,LV_OBJ_FLAG_HIDDEN);
	}


	return 0;
}
static int ui_puri_mode1_create(lv_obj_t* superview,ui_dev_purifier_t* puri)
{
	char txt[128] = {0};
	//*****************************************************************
	puri->ui.mode1.js = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode1.js,9,66);
	lv_obj_set_size(puri->ui.mode1.js, 140, 80);

	lv_label_set_long_mode(puri->ui.mode1.js, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode1.js,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode1.js,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode1.js, lv_font_get(70), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode1.js,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.jstds);
	lv_label_set_text(puri->ui.mode1.js,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode1.js, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode1.js, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode1.js, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	puri->ui.mode1.js_title = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode1.js_title,9,152);
	lv_obj_set_size(puri->ui.mode1.js_title,120,28);

	lv_label_set_long_mode(puri->ui.mode1.js_title, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode1.js_title,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode1.js_title,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode1.js_title, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode1.js_title,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	lv_label_set_text(puri->ui.mode1.js_title,"进水TDS");

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode1.js_title, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode1.js_title, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode1.js_title, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	puri->ui.mode1.cs = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode1.cs,166,66);
	lv_obj_set_size(puri->ui.mode1.cs, 140,80);

	lv_label_set_long_mode(puri->ui.mode1.cs, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode1.cs,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode1.cs,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode1.cs, lv_font_get(70), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode1.cs,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.cstds);
	lv_label_set_text(puri->ui.mode1.cs,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode1.cs, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode1.cs, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode1.cs, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	puri->ui.mode1.cs_title = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode1.cs_title,166,152);
	lv_obj_set_size(puri->ui.mode1.cs_title,120,28);

	lv_label_set_long_mode(puri->ui.mode1.cs_title, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode1.cs_title,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode1.cs_title,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode1.cs_title, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode1.cs_title,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	lv_label_set_text(puri->ui.mode1.cs_title,"纯水TDS");

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode1.cs_title, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode1.cs_title, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode1.cs_title, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	//滤芯1

	puri->ui.mode1.filter1 = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode1.filter1,296,84);
	lv_obj_set_size(puri->ui.mode1.filter1,160,28);

	lv_label_set_long_mode(puri->ui.mode1.filter1, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode1.filter1,LV_TEXT_ALIGN_LEFT,0);
	lv_obj_set_style_text_opa(puri->ui.mode1.filter1,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode1.filter1, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode1.filter1,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%s:%d%%",puri->data.f_info[0].name,puri->data.f_info[0].life);
	lv_label_set_text(puri->ui.mode1.filter1,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode1.filter1, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode1.filter1, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode1.filter1, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************
	//滤芯2

	puri->ui.mode1.filter2 = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode1.filter2,296,117);
	lv_obj_set_size(puri->ui.mode1.filter2,160,28);

	lv_label_set_long_mode(puri->ui.mode1.filter2, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode1.filter2,LV_TEXT_ALIGN_LEFT,0);
	lv_obj_set_style_text_opa(puri->ui.mode1.filter2,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode1.filter2, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode1.filter2,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%s:%d%%",puri->data.f_info[1].name,puri->data.f_info[1].life);
	lv_label_set_text(puri->ui.mode1.filter2,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode1.filter2, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode1.filter2, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode1.filter2, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************
	//滤芯3

	puri->ui.mode1.filter3 = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode1.filter3,296,149);
	lv_obj_set_size(puri->ui.mode1.filter3,160,28);

	lv_label_set_long_mode(puri->ui.mode1.filter3, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode1.filter3,LV_TEXT_ALIGN_LEFT,0);
	lv_obj_set_style_text_opa(puri->ui.mode1.filter3,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode1.filter3, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode1.filter3,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%s:%d%%",puri->data.f_info[2].name,puri->data.f_info[2].life);
	lv_label_set_text(puri->ui.mode1.filter3,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode1.filter3, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode1.filter3, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode1.filter3, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************

	if(puri->data.filter_num == 1)
	{
		lv_obj_set_pos(puri->ui.mode1.filter1,296,110);
		lv_obj_add_flag(puri->ui.mode1.filter2,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode1.filter3,LV_OBJ_FLAG_HIDDEN);
	}
	else if(puri->data.filter_num == 2)
	{
		lv_obj_set_pos(puri->ui.mode1.filter1,296,90);
		lv_obj_set_pos(puri->ui.mode1.filter2,296,130);
		lv_obj_add_flag(puri->ui.mode1.filter3,LV_OBJ_FLAG_HIDDEN);
	}
	//*****************************************************************

	return 0;
}

static int ui_puri_mode2_show(ui_dev_purifier_t* puri)
{
	lv_obj_clear_flag(puri->ui.mode2.js,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode2.js_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_clear_flag(puri->ui.mode2.cs,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode2.cs_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_clear_flag(puri->ui.mode2.filter1,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode2.filter_per,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode2.filter_title,LV_OBJ_FLAG_HIDDEN);

	return 0;
}

static int ui_puri_mode2_hide(ui_dev_purifier_t* puri)
{
	lv_obj_add_flag(puri->ui.mode2.js,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode2.js_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_add_flag(puri->ui.mode2.cs,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode2.cs_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_add_flag(puri->ui.mode2.filter1,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode2.filter_per,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode2.filter_title,LV_OBJ_FLAG_HIDDEN);

	return 0;
}

static int ui_puri_mode2_update(ui_dev_purifier_t* puri)
{
	char txt[128] = {0};

	if(!puri){
		return -1;
	}

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.jstds);
	lv_label_set_text(puri->ui.mode2.js,txt);

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.cstds);
	lv_label_set_text(puri->ui.mode2.cs,txt);

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.f_info[0].life);
	lv_label_set_text(puri->ui.mode2.filter1,txt);

	if(puri->data.f_info[0].life < 10){
		lv_obj_set_pos(puri->ui.mode2.filter_per,400,114);
	}else if(puri->data.f_info[0].life < 100){
		lv_obj_set_pos(puri->ui.mode2.filter_per,420,114);
	}else{
		lv_obj_set_pos(puri->ui.mode2.filter_per,440,114);
	}

	return 0;
}


static int ui_puri_mode2_create(lv_obj_t* superview,ui_dev_purifier_t* puri)
{
	char txt[128] = {0};
	//*****************************************************************
	puri->ui.mode2.js = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode2.js,9,66);
	lv_obj_set_size(puri->ui.mode2.js, 120, 80);

	lv_label_set_long_mode(puri->ui.mode2.js, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode2.js,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode2.js,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode2.js, lv_font_get(70), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode2.js,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.jstds);
	lv_label_set_text(puri->ui.mode2.js,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode2.js, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode2.js, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode2.js, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	puri->ui.mode2.js_title = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode2.js_title,9,152);
	lv_obj_set_size(puri->ui.mode2.js_title,120,28);

	lv_label_set_long_mode(puri->ui.mode2.js_title, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode2.js_title,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode2.js_title,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode2.js_title, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode2.js_title,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	lv_label_set_text(puri->ui.mode2.js_title,"进水TDS");

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode2.js_title, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode2.js_title, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode2.js_title, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	puri->ui.mode2.cs = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode2.cs,166,66);
	lv_obj_set_size(puri->ui.mode2.cs, 140,80);

	lv_label_set_long_mode(puri->ui.mode2.cs, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode2.cs,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode2.cs,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode2.cs, lv_font_get(70), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode2.cs,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.cstds);
	lv_label_set_text(puri->ui.mode2.cs,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode2.cs, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode2.cs, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode2.cs, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	puri->ui.mode2.cs_title = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode2.cs_title,166,152);
	lv_obj_set_size(puri->ui.mode2.cs_title,120,28);

	lv_label_set_long_mode(puri->ui.mode2.cs_title, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode2.cs_title,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode2.cs_title,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode2.cs_title, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode2.cs_title,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	lv_label_set_text(puri->ui.mode2.cs_title,"纯水TDS");

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode2.cs_title, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode2.cs_title, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode2.cs_title, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	//滤芯1

	puri->ui.mode2.filter1 = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode2.filter1,305,66);
	lv_obj_set_size(puri->ui.mode2.filter1,140,80);

	lv_label_set_long_mode(puri->ui.mode2.filter1, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode2.filter1,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode2.filter1,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode2.filter1, lv_font_get(70), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode2.filter1,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.f_info[0].life);
	lv_label_set_text(puri->ui.mode2.filter1,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode2.filter1, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode2.filter1, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode2.filter1, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************
	puri->ui.mode2.filter_per = lv_label_create(superview);

	
	lv_obj_set_size(puri->ui.mode2.filter_per,31,28);

	if(puri->data.f_info[0].life < 10){
		lv_obj_set_pos(puri->ui.mode2.filter_per,400,114);
	}else if(puri->data.f_info[0].life < 100){
		lv_obj_set_pos(puri->ui.mode2.filter_per,420,114);
	}else{
		lv_obj_set_pos(puri->ui.mode2.filter_per,440,114);
	}

	lv_label_set_long_mode(puri->ui.mode2.filter_per, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode2.filter_per,LV_TEXT_ALIGN_LEFT,0);
	lv_obj_set_style_text_opa(puri->ui.mode2.filter_per,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode2.filter_per, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode2.filter_per,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%%");
	lv_label_set_text(puri->ui.mode2.filter_per,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode2.filter_per, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode2.filter_per, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode2.filter_per, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************
	puri->ui.mode2.filter_title = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode2.filter_title,322,152);
	lv_obj_set_size(puri->ui.mode2.filter_title,140,28);

	lv_label_set_long_mode(puri->ui.mode2.filter_title, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode2.filter_title,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode2.filter_title,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode2.filter_title, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode2.filter_title,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%s",puri->data.f_info[0].name);
	lv_label_set_text(puri->ui.mode2.filter_title,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode2.filter_title, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode2.filter_title, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode2.filter_title, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************

	return 0;
}

static int ui_puri_mode3_show(ui_dev_purifier_t* puri)
{
	lv_obj_clear_flag(puri->ui.mode3.filter1,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode3.filter1_per,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode3.filter1_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_clear_flag(puri->ui.mode3.filter2,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode3.filter2_per,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode3.filter2_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_clear_flag(puri->ui.mode3.filter3,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode3.filter3_per,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.mode3.filter3_title,LV_OBJ_FLAG_HIDDEN);

	if(puri->data.filter_num == 1)
	{
		lv_obj_add_flag(puri->ui.mode3.filter2,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter2_per,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter2_title,LV_OBJ_FLAG_HIDDEN);
	
		lv_obj_add_flag(puri->ui.mode3.filter3,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter3_per,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter3_title,LV_OBJ_FLAG_HIDDEN);
	}
	else if(puri->data.filter_num == 2)
	{
		lv_obj_add_flag(puri->ui.mode3.filter3,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter3_per,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter3_title,LV_OBJ_FLAG_HIDDEN);
	}

	return 0;
}

static int ui_puri_mode3_hide(ui_dev_purifier_t* puri)
{
	lv_obj_add_flag(puri->ui.mode3.filter1,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode3.filter1_per,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode3.filter1_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_add_flag(puri->ui.mode3.filter2,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode3.filter2_per,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode3.filter2_title,LV_OBJ_FLAG_HIDDEN);

	lv_obj_add_flag(puri->ui.mode3.filter3,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode3.filter3_per,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.mode3.filter3_title,LV_OBJ_FLAG_HIDDEN);

	return 0;
}

static int ui_puri_mode3_update(ui_dev_purifier_t* puri)
{
	char txt[128] = {0};

	if(!puri){
		return -1;
	}

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.f_info[0].life);
	lv_label_set_text(puri->ui.mode3.filter1,txt);

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.f_info[1].life);
	lv_label_set_text(puri->ui.mode3.filter2,txt);

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.f_info[2].life);
	lv_label_set_text(puri->ui.mode3.filter3,txt);

	if(puri->data.filter_num == 1)
	{
		lv_obj_set_pos(puri->ui.mode3.filter1,160,66);
		lv_obj_set_pos(puri->ui.mode3.filter1_per,260,104);
		lv_obj_set_pos(puri->ui.mode3.filter1_title,160,150);
		//**********************************/
		if(puri->data.f_info[0].life < 10){
			lv_obj_set_pos(puri->ui.mode3.filter1_per,240,104);
		}else if(puri->data.f_info[0].life < 100){
			lv_obj_set_pos(puri->ui.mode3.filter1_per,260,104);
		}else{
			lv_obj_set_pos(puri->ui.mode3.filter1_per,280,104);
		}
		//**********************************/

		lv_obj_add_flag(puri->ui.mode3.filter2,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter2_per,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter2_title,LV_OBJ_FLAG_HIDDEN);
	
		lv_obj_add_flag(puri->ui.mode3.filter3,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter3_per,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter3_title,LV_OBJ_FLAG_HIDDEN);
	}
	else if(puri->data.filter_num == 2)
	{
		lv_obj_set_pos(puri->ui.mode3.filter1,50,66);
		lv_obj_set_pos(puri->ui.mode3.filter1_per,150,104);
		lv_obj_set_pos(puri->ui.mode3.filter1_title,50,150);

		lv_obj_set_pos(puri->ui.mode3.filter2,280,66);
		lv_obj_set_pos(puri->ui.mode3.filter2_per,380,104);
		lv_obj_set_pos(puri->ui.mode3.filter2_title,280,150);

		//*************************************** */
		if(puri->data.f_info[0].life < 10){
			lv_obj_set_pos(puri->ui.mode3.filter1_per,130,104);
		}else if(puri->data.f_info[0].life < 100){
			lv_obj_set_pos(puri->ui.mode3.filter1_per,150,104);
		}else{
			lv_obj_set_pos(puri->ui.mode3.filter1_per,170,104);
		}
		//**********************************
		if(puri->data.f_info[1].life < 10){
			lv_obj_set_pos(puri->ui.mode3.filter2_per,360,104);
		}else if(puri->data.f_info[1].life < 100){
			lv_obj_set_pos(puri->ui.mode3.filter2_per,380,104);
		}else{
			lv_obj_set_pos(puri->ui.mode3.filter2_per,400,104);
		}
		//*************************************** */
	
		lv_obj_add_flag(puri->ui.mode3.filter3,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter3_per,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.mode3.filter3_title,LV_OBJ_FLAG_HIDDEN);
	}
	else{

		if(puri->data.f_info[0].life < 10){
			lv_obj_set_pos(puri->ui.mode3.filter1_per,80,104);
		}else if(puri->data.f_info[0].life < 100){
			lv_obj_set_pos(puri->ui.mode3.filter1_per,100,104);
		}else{
			lv_obj_set_pos(puri->ui.mode3.filter1_per,120,104);
		}
		//**********************************
		if(puri->data.f_info[1].life < 10){
			lv_obj_set_pos(puri->ui.mode3.filter2_per,240,104);
		}else if(puri->data.f_info[1].life < 100){
			lv_obj_set_pos(puri->ui.mode3.filter2_per,260,104);
		}else{
			lv_obj_set_pos(puri->ui.mode3.filter2_per,280,104);
		}
		//**********************************
		if(puri->data.f_info[2].life < 10){
			lv_obj_set_pos(puri->ui.mode3.filter3_per,400,104);
		}else if(puri->data.f_info[2].life < 100){
			lv_obj_set_pos(puri->ui.mode3.filter3_per,420,104);
		}else{
			lv_obj_set_pos(puri->ui.mode3.filter3_per,440,104);
		}
		//**********************************
	}


	return 0;
}

static int ui_puri_mode3_create(lv_obj_t* superview,ui_dev_purifier_t* puri)
{
	char txt[128] = {0};
	//*****************************************************************
	//滤芯1

	puri->ui.mode3.filter1 = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode3.filter1,0,66);
	lv_obj_set_size(puri->ui.mode3.filter1,120,70);

	lv_label_set_long_mode(puri->ui.mode3.filter1, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode3.filter1,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode3.filter1,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode3.filter1, lv_font_get(60), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode3.filter1,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.f_info[0].life);
	lv_label_set_text(puri->ui.mode3.filter1,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter1, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter1, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode3.filter1, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************
	puri->ui.mode3.filter1_per = lv_label_create(superview);

	if(puri->data.f_info[0].life < 10){
		lv_obj_set_pos(puri->ui.mode3.filter1_per,80,104);
	}else if(puri->data.f_info[0].life < 100){
		lv_obj_set_pos(puri->ui.mode3.filter1_per,100,104);
	}else{
		lv_obj_set_pos(puri->ui.mode3.filter1_per,120,104);
	}

	lv_obj_set_size(puri->ui.mode3.filter1_per,31,28);

	lv_label_set_long_mode(puri->ui.mode3.filter1_per, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode3.filter1_per,LV_TEXT_ALIGN_LEFT,0);
	lv_obj_set_style_text_opa(puri->ui.mode3.filter1_per,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode3.filter1_per, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode3.filter1_per,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%%");
	lv_label_set_text(puri->ui.mode3.filter1_per,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter1_per, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter1_per, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode3.filter1_per, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************
	puri->ui.mode3.filter1_title = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode3.filter1_title,6,150);
	lv_obj_set_size(puri->ui.mode3.filter1_title,140,28);

	lv_label_set_long_mode(puri->ui.mode3.filter1_title, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode3.filter1_title,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode3.filter1_title,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode3.filter1_title, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode3.filter1_title,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%s",puri->data.f_info[0].name);
	lv_label_set_text(puri->ui.mode3.filter1_title,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter1_title, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter1_title, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode3.filter1_title, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	//滤芯2

	puri->ui.mode3.filter2 = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode3.filter2,161,66);
	lv_obj_set_size(puri->ui.mode3.filter2,120,70);

	lv_label_set_long_mode(puri->ui.mode3.filter2, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode3.filter2,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode3.filter2,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode3.filter2, lv_font_get(60), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode3.filter2,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.f_info[1].life);
	lv_label_set_text(puri->ui.mode3.filter2,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter2, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter2, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode3.filter2, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************
	puri->ui.mode3.filter2_per = lv_label_create(superview);

	lv_obj_set_size(puri->ui.mode3.filter2_per,31,28);

	if(puri->data.f_info[1].life < 10){
		lv_obj_set_pos(puri->ui.mode3.filter2_per,240,104);
	}else if(puri->data.f_info[1].life < 100){
		lv_obj_set_pos(puri->ui.mode3.filter2_per,260,104);
	}else{
		lv_obj_set_pos(puri->ui.mode3.filter2_per,280,104);
	}

	lv_label_set_long_mode(puri->ui.mode3.filter2_per, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode3.filter2_per,LV_TEXT_ALIGN_LEFT,0);
	lv_obj_set_style_text_opa(puri->ui.mode3.filter2_per,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode3.filter2_per, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode3.filter2_per,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%%");
	lv_label_set_text(puri->ui.mode3.filter2_per,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter2_per, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter2_per, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode3.filter2_per, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************
	puri->ui.mode3.filter2_title = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode3.filter2_title,161,150);
	lv_obj_set_size(puri->ui.mode3.filter2_title,140,28);

	lv_label_set_long_mode(puri->ui.mode3.filter2_title, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode3.filter2_title,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode3.filter2_title,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode3.filter2_title, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode3.filter2_title,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%s",puri->data.f_info[1].name);
	lv_label_set_text(puri->ui.mode3.filter2_title,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter2_title, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter2_title, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode3.filter2_title, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	//滤芯3

	puri->ui.mode3.filter3 = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode3.filter3,322,66);
	lv_obj_set_size(puri->ui.mode3.filter3,120,70);

	lv_label_set_long_mode(puri->ui.mode3.filter3, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode3.filter3,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode3.filter3,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode3.filter3, lv_font_get(60), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode3.filter3,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%d",puri->data.f_info[2].life);
	lv_label_set_text(puri->ui.mode3.filter3,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter3, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter3, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode3.filter3, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************
	puri->ui.mode3.filter3_per = lv_label_create(superview);

	lv_obj_set_size(puri->ui.mode3.filter3_per,31,28);

	if(puri->data.f_info[2].life < 10){
		lv_obj_set_pos(puri->ui.mode3.filter3_per,400,104);
	}else if(puri->data.f_info[2].life < 100){
		lv_obj_set_pos(puri->ui.mode3.filter3_per,420,104);
	}else{
		lv_obj_set_pos(puri->ui.mode3.filter3_per,440,104);
	}

	lv_label_set_long_mode(puri->ui.mode3.filter3_per, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode3.filter3_per,LV_TEXT_ALIGN_LEFT,0);
	lv_obj_set_style_text_opa(puri->ui.mode3.filter3_per,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode3.filter3_per, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode3.filter3_per,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%%");
	lv_label_set_text(puri->ui.mode3.filter3_per,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter3_per, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter3_per, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode3.filter3_per, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif	
	//*****************************************************************
	puri->ui.mode3.filter3_title = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode3.filter3_title,322,150);
	lv_obj_set_size(puri->ui.mode3.filter3_title,140,28);

	lv_label_set_long_mode(puri->ui.mode3.filter3_title, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode3.filter3_title,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode3.filter3_title,LV_OPA_40,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode3.filter3_title, lv_font_get(20), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode3.filter3_title,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	memset(txt,0,sizeof(txt));
	snprintf(txt,sizeof(txt),"%s",puri->data.f_info[2].name);
	lv_label_set_text(puri->ui.mode3.filter3_title,txt);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter3_title, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode3.filter3_title, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode3.filter3_title, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif
	//*****************************************************************
	ui_puri_mode3_update(puri);
	//*****************************************************************

	return 0;
}

static int ui_puri_mode4_show(ui_dev_purifier_t* puri)
{
	//title
	lv_obj_add_flag(puri->ui.label_status,LV_OBJ_FLAG_HIDDEN);

	lv_obj_clear_flag(puri->ui.mode4.lab_status,LV_OBJ_FLAG_HIDDEN);

	return 0;
}


static int ui_puri_mode4_hide(ui_dev_purifier_t* puri)
{
	//title
	lv_obj_clear_flag(puri->ui.label_status,LV_OBJ_FLAG_HIDDEN);

	lv_obj_add_flag(puri->ui.mode4.lab_status,LV_OBJ_FLAG_HIDDEN);

	return 0;
}

static int ui_puri_mode4_update(ui_dev_purifier_t* puri)
{
	char txt[128] = {0};

	lv_label_set_text(puri->ui.mode4.lab_status,puri_wsta[puri->data.workstatus]);

	return 0;
}

static int ui_puri_mode4_create(lv_obj_t* superview,ui_dev_purifier_t* puri)
{
	puri->ui.mode4.lab_status = lv_label_create(superview);

	lv_obj_set_pos(puri->ui.mode4.lab_status,108,85);
	lv_obj_set_size(puri->ui.mode4.lab_status,264,80);

	lv_label_set_long_mode(puri->ui.mode4.lab_status, LV_LABEL_LONG_WRAP);
	lv_obj_set_style_text_align(puri->ui.mode4.lab_status,LV_TEXT_ALIGN_CENTER,0);
	lv_obj_set_style_text_opa(puri->ui.mode4.lab_status,LV_OPA_80,LV_PART_MAIN);
	lv_obj_set_style_text_font(puri->ui.mode4.lab_status, lv_font_get(70), LV_PART_MAIN);
	lv_obj_set_style_text_color(puri->ui.mode4.lab_status,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 

	lv_label_set_text(puri->ui.mode4.lab_status,puri_wsta[puri->data.workstatus]);

#if DEBUG_PURI
	lv_obj_set_style_bg_opa(puri->ui.mode4.lab_status, LV_OPA_0, LV_PART_MAIN);
#else
	lv_obj_set_style_bg_opa(puri->ui.mode4.lab_status, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(puri->ui.mode4.lab_status, lv_color_make(0xFF, 0, 0), LV_PART_MAIN);
#endif


	return 0;
}

static int ui_dev_purifier_update(ui_dev_purifier_t* puri)
{
	int ret = 0;
	char txt[128] = {0};

	if(!puri){
		return -1;
	}

	ui_puri_mode1_update(puri);
	ui_puri_mode2_update(puri);
	ui_puri_mode3_update(puri);
	ui_puri_mode4_update(puri);
	//******************************************
	switch(puri->data.status){
	case DEV_WORK:
	{
		ui_dev_puri_show(puri);
		ui_dev_off_hide(&puri->ui.dev_off);
		ui_dev_off_line_hide(&puri->ui.dev_off_line);
		break;
	}
	case DEV_OFF:
	{
		ui_dev_puri_hide(puri);
		ui_dev_off_show(&puri->ui.dev_off);
		ui_dev_off_line_hide(&puri->ui.dev_off_line);
		break;
	}
	case DEV_OFF_LINE:
	{
		ui_dev_puri_hide(puri);
		ui_dev_off_hide(&puri->ui.dev_off);
		ui_dev_off_line_show(&puri->ui.dev_off_line);
		break;
	}
	default:break;
	}
	//******************************************
	if(puri->data.workstatus == PURIFIER_STAT_WARM){
		lv_img_set_src(puri->ui.bg_img,&BG_orange);
	}else if(puri->data.workstatus == PURIFIER_STAT_HEAT){
		lv_img_set_src(puri->ui.bg_img,&BG_orange);
	}else{
		lv_img_set_src(puri->ui.bg_img,&BG_Blue);
	}
	//******************************************
	lv_label_set_text(puri->ui.label_status,puri_wsta[puri->data.workstatus]);
	lv_img_set_src(puri->ui.wash_img,pt_fs_get(icon_washing[puri->data.wash_status]));
	lv_img_set_src(puri->ui.heat_img,pt_fs_get(icon_heating[puri->data.heat_status]));
	//******************************************

	if((puri->data.is_exist_heat)&&(!puri->data.is_exist_wash))
	{
		//只有加热
		lv_obj_set_pos(puri->ui.heat_btn,200,195);
		lv_obj_set_pos(puri->ui.heat_img,200,195);
		lv_obj_set_pos(puri->ui.heat_lab,185,290);
		//****************************
		lv_obj_add_flag(puri->ui.wash_btn,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.wash_img,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.wash_lab,LV_OBJ_FLAG_HIDDEN);
	}
	else if((!puri->data.is_exist_heat)&&(puri->data.is_exist_wash))
	{
		//只有滤芯冲洗

		lv_obj_add_flag(puri->ui.heat_btn,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.heat_img,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.heat_lab,LV_OBJ_FLAG_HIDDEN);
		//****************************
		lv_obj_set_pos(puri->ui.wash_btn,200,195);
		lv_obj_set_pos(puri->ui.wash_img,200,195);
		lv_obj_set_pos(puri->ui.wash_lab,185,290);
		//****************************
	}
	//******************************************
	switch(puri->data.workstatus){
	case PURIFIER_STAT_WARM:
	case PURIFIER_STAT_STANDBY:
	{
		if(puri->data.is_exist_tds)
		{
			if(puri->data.is_exist_rofilter)
			{
				ui_puri_mode1_hide(puri);
				ui_puri_mode2_show(puri);
				ui_puri_mode3_hide(puri);
				ui_puri_mode4_hide(puri);
			}
			else{
				ui_puri_mode1_show(puri);
				ui_puri_mode2_hide(puri);
				ui_puri_mode3_hide(puri);
				ui_puri_mode4_hide(puri);
			}
		}
		else{

			ui_puri_mode1_hide(puri);
			ui_puri_mode2_hide(puri);
			ui_puri_mode3_show(puri);
			ui_puri_mode4_hide(puri);
		}
		break;
	}
	case PURIFIER_STAT_HEAT:
	case PURIFIER_STAT_WASH:
	case PURIFIER_STAT_FILTER:
	case PURIFIER_STAT_OUT_WATER:
	case PURIFIER_STAT_UV_STERILIZE:
	case PURIFIER_STAT_ERR:
	{
		ui_puri_mode1_hide(puri);
		ui_puri_mode2_hide(puri);
		ui_puri_mode3_hide(puri);
		ui_puri_mode4_show(puri);
		break;
	}
	default:break;
	}
	//******************************************

	return 0;
}

static void purifier_timer_cb(struct _lv_timer_t *t)
{
   ui_dev_purifier_t* puri      = NULL;
   puri = (ui_dev_purifier_t*)t->user_data;

   if(!puri->ui.time){
		return ;
   }

   ui_dev_purifier_update(puri);
}

int ui_init_dev_purifier_page(lv_obj_t* parent,void* ui_data)
{
	char txt[128];
    lv_obj_t*          superview = parent;
    ui_dev_purifier_t* puri      = (ui_dev_purifier_t*)ui_data;

	if(puri->data.workstatus >= sizeof(puri_wsta)/sizeof(puri_wsta[0]))
	{
		puri->data.workstatus = PURIFIER_STAT_WARM;			
	}
	//********************************************
    puri->ui.bg_img = lv_img_create(superview);
	lv_obj_set_pos(puri->ui.bg_img,0,0);

	if(puri->data.workstatus == PURIFIER_STAT_WARM){
		lv_img_set_src(puri->ui.bg_img,&BG_orange);
	}
	else if(puri->data.workstatus == PURIFIER_STAT_HEAT){
		lv_img_set_src(puri->ui.bg_img,&BG_orange);
	}else{
		lv_img_set_src(puri->ui.bg_img,&BG_Blue);
	}
	//********************************************
	puri->ui.label_status = lv_label_create(superview);
	lv_label_set_text(puri->ui.label_status,puri_wsta[puri->data.workstatus]);
	lv_label_set_long_mode(puri->ui.label_status, LV_LABEL_LONG_WRAP);
	lv_obj_set_pos(puri->ui.label_status, 177, 40);
	lv_obj_set_size(puri->ui.label_status, 84, 28);
    lv_obj_set_style_text_align(puri->ui.label_status,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_opa(puri->ui.label_status,LV_OPA_80,LV_PART_MAIN);
    lv_obj_set_style_text_color(puri->ui.label_status,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_obj_set_style_text_font(puri->ui.label_status, lv_font_get(20), LV_PART_MAIN);
	//********************************************
	//创建滤芯重新 加热按钮

	ui_puri_ctl_button(superview,puri);
	//********************************************
	ui_puri_mode1_create(superview,puri);
	ui_puri_mode2_create(superview,puri);
	ui_puri_mode3_create(superview,puri);
	ui_puri_mode4_create(superview,puri);
	//********************************************
    puri->ui.time = lv_timer_create(purifier_timer_cb,1000,(void*)puri);
	//********************************************
	
    return 0;
}

int ui_dev_purifier_page_destroy(void* ui_data)
{
    ui_dev_purifier_t* puri  = (ui_dev_purifier_t*)ui_data;

	if(puri->ui.time){
		lv_timer_del(puri->ui.time);
		puri->ui.time = NULL;
	}

	return 0;
}

int ui_dev_puri_show(ui_dev_purifier_t* puri)
{
    if(!puri){
        return -1;
    }

	lv_obj_clear_flag(puri->ui.bg_img,LV_OBJ_FLAG_HIDDEN);
	lv_obj_clear_flag(puri->ui.label_status,LV_OBJ_FLAG_HIDDEN);

	if((puri->data.is_exist_heat)&&(!puri->data.is_exist_wash))
	{
		lv_obj_clear_flag(puri->ui.heat_img,LV_OBJ_FLAG_HIDDEN);
		lv_obj_clear_flag(puri->ui.heat_btn,LV_OBJ_FLAG_HIDDEN);
		lv_obj_clear_flag(puri->ui.heat_lab,LV_OBJ_FLAG_HIDDEN);

		lv_obj_add_flag(puri->ui.wash_btn,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.wash_img,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.wash_lab,LV_OBJ_FLAG_HIDDEN);
	}
	else if((!puri->data.is_exist_heat)&&(puri->data.is_exist_wash))
	{
		lv_obj_add_flag(puri->ui.heat_img,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.heat_btn,LV_OBJ_FLAG_HIDDEN);
		lv_obj_add_flag(puri->ui.heat_lab,LV_OBJ_FLAG_HIDDEN);

		lv_obj_clear_flag(puri->ui.wash_btn,LV_OBJ_FLAG_HIDDEN);
		lv_obj_clear_flag(puri->ui.wash_img,LV_OBJ_FLAG_HIDDEN);
		lv_obj_clear_flag(puri->ui.wash_lab,LV_OBJ_FLAG_HIDDEN);	
	}

	switch(puri->data.workstatus){
	case PURIFIER_STAT_WARM:
	case PURIFIER_STAT_STANDBY:
	{
		if(puri->data.is_exist_tds)
		{
			if(puri->data.is_exist_rofilter)
			{
				ui_puri_mode1_hide(puri);
				ui_puri_mode2_show(puri);
				ui_puri_mode3_hide(puri);
				ui_puri_mode4_hide(puri);
			}
			else{
				ui_puri_mode1_show(puri);
				ui_puri_mode2_hide(puri);
				ui_puri_mode3_hide(puri);
				ui_puri_mode4_hide(puri);
			}
		}
		else{

			ui_puri_mode1_hide(puri);
			ui_puri_mode2_hide(puri);
			ui_puri_mode3_show(puri);
			ui_puri_mode4_hide(puri);
		}
		break;
	}
	case PURIFIER_STAT_HEAT:
	case PURIFIER_STAT_WASH:
	case PURIFIER_STAT_FILTER:
	case PURIFIER_STAT_OUT_WATER:
	case PURIFIER_STAT_UV_STERILIZE:
	case PURIFIER_STAT_ERR:
	{
		ui_puri_mode1_hide(puri);
		ui_puri_mode2_hide(puri);
		ui_puri_mode3_hide(puri);
		ui_puri_mode4_show(puri);
		break;
	}
	default:break;
	}
	
	return 0;
}

int ui_dev_puri_hide(ui_dev_purifier_t* puri)
{
    if(!puri){
        return -1;
    }

	lv_obj_add_flag(puri->ui.bg_img,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.label_status,LV_OBJ_FLAG_HIDDEN);

	lv_obj_add_flag(puri->ui.wash_img,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.wash_btn,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.wash_lab,LV_OBJ_FLAG_HIDDEN);

	lv_obj_add_flag(puri->ui.heat_img,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.heat_btn,LV_OBJ_FLAG_HIDDEN);
	lv_obj_add_flag(puri->ui.heat_lab,LV_OBJ_FLAG_HIDDEN);
	
	ui_puri_mode1_hide(puri);
	ui_puri_mode2_hide(puri);
	ui_puri_mode3_hide(puri);
	ui_puri_mode4_hide(puri);

	return 0;
}

static int ui_purifier_create(lv_obj_t* parent,void* ui_data)
{
    lv_obj_t* superview     = parent;
    ui_dev_purifier_t* puri = (ui_dev_purifier_t*)ui_data;

	debug_d("puri create\n");

	ui_init_dev_purifier_page(parent,ui_data);
	ui_dev_off_create(superview,&puri->ui.dev_off);
    ui_dev_off_line_create(superview,&puri->ui.dev_off_line);

	switch(puri->data.status){
	case DEV_WORK:
	{
		ui_dev_puri_show(puri);
		ui_dev_off_hide(&puri->ui.dev_off);
		ui_dev_off_line_hide(&puri->ui.dev_off_line);
		break;
	}
	case DEV_OFF:
	{
		ui_dev_puri_hide(puri);
		ui_dev_off_show(&puri->ui.dev_off);
		ui_dev_off_line_hide(&puri->ui.dev_off_line);
		break;
	}
	case DEV_OFF_LINE:
	{
		ui_dev_puri_hide(puri);
		ui_dev_off_hide(&puri->ui.dev_off);
		ui_dev_off_line_show(&puri->ui.dev_off_line);
		break;
	}
	default:break;
	}

	debug_d("puri end\n");

	return 0;
}

static int ui_purifier_destroy(void* ui_data)
{
    ui_dev_purifier_t* puri = (ui_dev_purifier_t*)ui_data;

	ui_dev_off_destroy(&puri->ui.dev_off);
    ui_dev_off_line_destroy(&puri->ui.dev_off_line);
	ui_dev_purifier_page_destroy(ui_data);

	return 0;
}
static void on_custom_attr_config(page_base_t* self)
{
}
static void on_view_load(page_base_t* self)
{
}
static void on_view_did_load(page_base_t* self)
{
}
static void on_view_will_appear(page_base_t* self)
{
}
static void on_view_did_appear(page_base_t* self)
{
}
static void on_view_will_disappear(page_base_t* self)
{
}
static void on_view_did_disappear(page_base_t* self)
{
}
static void on_view_did_unload(page_base_t* self)
{
}

dev_info_t* dev_purifier_reg(ui_puri_data_t* dev)
{
    int len = 0;
    ui_dev_purifier_t* device   = NULL;
    page_vtable_t*     method   = NULL;
    dev_info_t*        devinfo  = NULL;

    devinfo = (dev_info_t*)malloc(sizeof(dev_info_t));
    if(!devinfo){
        debug_d("merr\n");
        return NULL;
    }

    device = (ui_dev_purifier_t*)malloc(sizeof(ui_dev_purifier_t));
    if(!device){
        debug_d("merr\n");
        return NULL;
    }
	memset(device,0,sizeof(ui_dev_purifier_t));

    method = (page_vtable_t*)malloc(sizeof(page_vtable_t));
    if(!method){
        debug_d("merr\n");
        return NULL;
    }
    //***********************************************************
    method->on_custom_attr_config  = on_custom_attr_config;
    method->on_view_load           = on_view_load;
    method->on_view_did_load       = on_view_did_load;
    method->on_view_will_appear    = on_view_will_appear;
    method->on_view_did_appear     = on_view_did_appear;
    method->on_view_will_disappear = on_view_will_disappear;
    method->on_view_did_disappear  = on_view_did_disappear;
    method->on_view_did_unload     = on_view_did_unload;
    //***********************************************************

	memcpy(&device->data,dev,sizeof(ui_puri_data_t));
    //***********************************************************
    devinfo->method     = method;    
    devinfo->priv_data  = (void*)device;
    //***********************************************************

    return devinfo;
}

int dev_purifier_unreg(dev_info_t* devinfo)
{
    


    return 0;
}


static void dev_purifier_on_page_create(lv_obj_t* parent,void* ui_data)
{
    debug_d("create\n");
    ui_purifier_create(parent,ui_data);
}
static void dev_purifier_on_page_destroy(void* ui_data)
{
    debug_d("destroy\n");
	ui_purifier_destroy(ui_data);
}
static void dev_purifier_on_page_update(void* ui_data)
{

}

page_info_t* dev_puri_page_reg(ui_dev_purifier_t* puri)
{
    page_method_t*  method  = NULL;
    page_info_t*    page    = NULL;

    page = (page_info_t*)malloc(sizeof(page_info_t));
    if(!page){
        debug_e("err0\n");
        return NULL;
    }
    method = (page_method_t*)malloc(sizeof(page_method_t));
    if(!method){
        debug_e("err1\n");
        return NULL;
    }
    //***********************************************************
    method->on_page_create  = dev_purifier_on_page_create;
    method->on_page_destroy = dev_purifier_on_page_destroy;
    method->on_page_update  = dev_purifier_on_page_update;
    //***********************************************************
    page->method  = method;    
    page->data    = (void*)puri;
    //***********************************************************

    return page;
}